# -*- coding: utf-8 -*-
"""
-------------------------------------------------
   File Name：     11test_login.py
   Description :   
   Author :        ZhangYiLin
   date：          2020/12/07 16:54
-------------------------------------------------
   Change Activity:
                   2020/12/07 16:54
-------------------------------------------------
"""
import os
import allure
import pytest
from common.InCase import init_case


PATH = os.path.split(os.path.realpath(__file__))[0]
login_data = init_case(PATH)
@allure.feature('登录测试')
class TestLogin:

    @allure.story('登录测试')
    @allure.title('登陆测试，测试数据：{title}')
    @pytest.mark.parametrize('title, username, password', login_data)
    @pytest.mark.flaky(reruns=1, reruns_delay=1)
    def test_login(self, open_url, title, username, password):
        driver = open_url
        url1 = driver.get_current_url()
        driver.login(username, password)
        url2 = driver.get_current_url()
        if "成功" in title:
            assert url1 != url2, f'测试通过，用例为：{title, username, password}'
        else:
            assert url1 == url2, f'测试失败，用例为：{title, username, password}'


if __name__ == '__main__':
    pytest.main(['--reruns', '1', '--html=./report/testReport10_58_09.html'])